<?php

use yii\db\Migration;

class m191230_022917_admin extends Migration
{
    public function up()
    {
        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="管理员表"';
        $this->createTable('{{%admin}}', [
            'id' => $this->primaryKey(),
            'username' => $this->string()->notNull()->unique()->comment('用户名'),
            'password' => $this->string()->notNull()->comment('密码'),
            'salt' => $this->string(16)->notNull()->comment('盐'),
            'token' => $this->string()->unique()->comment('唯一标识'),
            'status' => $this->smallInteger()->notNull()->defaultValue(1)->comment('状态，1 正常 2禁用 3删除'),
            'super' => $this->smallInteger()->notNull()->defaultValue(2)->comment('1 超管 2普通'),
            'avatar' => $this->string()->comment('用户头像'),
            'true_name'=>$this->string()->notNull()->comment('真实姓名'),
            'mobile'=>$this->char(11)->comment('手机号'),
            'created_at' => $this->integer()->notNull(),
            'updated_at' => $this->integer()->notNull(),
            'deleted_at' => $this->integer(),
        ],$tableOptions);
    }

    public function down()
    {
        $this->dropTable('{{%admin}}');
        return false;
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}
